Chris Pollett > Old Classses >
CS116b/216

( Print View )

Student Corner:
  [Grades Sec1]
  [Submit Sec1]
  [Class Sign Up Sec1]
  [
Lecture Notes]
  [Discussion Board]

Course Info:
  [Texts & Links]
  [Topics/Outcomes]
  [Outcomes Matrix]
  [Grading]
  [Class Protocols]
  [HW/Quiz Info]
  [Exam Info]
  [Regrades]
  [Honesty]
  [Additional Policies]
  [Announcements]

HW Assignments:
  [Hw1]  [Hw2]  [Hw3]
  [Hw4]  [Hw5]  [Quizzes]

Practice Exams:
  [Midterm]  [Final]

                           












HW#4 --- last modified February 07 2019 04:26:37..

Solution set.

Due date: Apr 21

Files to be submitted:
  Hw4.zip

Purpose: To gain experience with ray-tracing. To gain experience with dynamic shader creation

Related Course Outcomes:

The main course outcomes covered by this assignment are:

LO6 -- Be able to implement a ray-tracing algorithm.

Specification:

CS 216 students will do the assignment described below and in addition look up the following papers in the library, read it and write a 1 page summary of what they got out of it. This should be put in the file Hw4.pdf which you include in your project ZIP file.

Whitted, T. An improved illumination model for shaded display. Communications of the ACM. Volume 23. Issue 6 (1980). pp343-349.

Grad students should also come see me before the next homework is due to discuss their final projects.

As part of the CS116B Hw4 in 2005, I wrote a ray tracer. For this homework, I would like you to update this program to do the ray-tracing in a shader. First, get the existing code to work in SDL as per HW3. Next in the interface rather than asking first for the light source position, then the tetrahedron location, then the cube location, then the sphere, it asks the user to select the type of the object to add: (a) light, (b) tetrahedron, (c) cube, (d) sphere, (e) cylinder, (f) cone. Here (e) and (f) are new. It then gets the location of the objects. If this is in a currently occupied location the old object is overridden. Finally, it asks if you would like to add another object. If you say yes, you go through the above again, on no, your program should draw the scene using ray-tracing. The old project did all of its ray-tracing in CPU-land in the function rayTraceScreen. I want your project to do ray-tracing in GPU-land using a fragment shader. The geometry which comes to the vertex shader from OpenGL for your project should consist of just two triangles representing the window. The objects in the scene to be rendered are passed to the vertex shader as uniform variable arrays and these are passed through to the fragment shader (along with gl_Position). Using a varying variable for position, the fragment shader knows where it is at within the square represented by the two triangles. So using this position we can shoot a ray out through our scene to do ray tracing and compute a color value to be drawn. In shader-land, you can make structs for things like triangles, spheres, cones, etc. You can also create arrays of structs for each primitive type you need. Since shaders are just strings before they are compiled, you can adjust your shader string based on the user inputs to be of the correct size to handle the user data. You can pass data collected from the user and send it to the shader using uniform variables. Structs in shaders are like C structs. Unlike C++, our fragment shader struct's cannot have member functions. So you will need to rewrite the intersect calculation as just functions which check against each member of the struct array for triangles, or which check against the struct array for cones, etc. The existing code does shadow rays and super sampling. You do not need to make these work in your shader to receive full credit.

Point Breakdown

Code contributed to existing project is well-documented and follows the SJSU CS Department guidelines for C++. (Undergrad version) Paper summary (Grad Version)1pt
Code rewritten using SDL1pt
New user interface as described1pt
Vertex shader as described1pt
Scene drawn using ray-tracing in the fragment shader. (1pt) At a minimum spheres and lights can be drawn at the user supplied locations as well as the checker. (1pt)2pts
Objects input by user sent to fragment shader as uniform variable1pt
Ray tracing intersections correctly calculated by shader for each of the five primitive types (0.5pt)2.5pts
Scene draws correctly under a variety of inputs0.5pts
Total10pts